package com.ats.serviceimpl;

import com.ats.dao.FunctionDao_xh;
import com.ats.daoimpl.FunctionDaoImpl_xh;
import com.ats.service.FunctionService_xh;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
 * 不同角色加载不同功能的Service层实现类
 * @author xh
 *
 */
public class FunctionServiceImpl_xh implements FunctionService_xh{
	FunctionDao_xh fdao = new FunctionDaoImpl_xh();
	
	public JSONArray getFuncs(int pid, String fids) {
		// TODO Auto-generated method stub
		 JSONArray  as =fdao.getFincByPid(pid, fids);
		 for(int i = 0; i < as.size(); i++) {
			    JSONObject  j = as.getJSONObject(i);
			    if(j.getString("state").equals("open")){
			    	continue;
			    }else{			    	
			    	JSONArray  childrens= this.getFuncs(j.getInt("id"),fids);
			    	j.put("children",childrens);
			    }
		}
		  return as ;
	}

}
